package cn.tedu.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.io.IOException;
//创建过滤器：implements Filter+重写抽象方法
//@WebFilter("/*")
@WebFilter("/order/*")
//拦截请求或响应，必须访问才会触发
public class Filter01 implements Filter {
    //销毁,执行1次
    public void destroy() {
        System.out.println("filter被销毁~~~");
    }
    //类似于Servlet的service(),会被执行多次
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        System.out.println("过滤器开始执行任务。。。");
        chain.doFilter(req, resp);//放行，解除阻塞状态
    }
    //初始化，执行1次
    public void init(FilterConfig config) throws ServletException {
        System.out.println("filter被初始化完成");
    }

}
